Typical HAL CCB use cases for migration

This section provides typical HAL CCB use cases to help migrate from HAL1 to HAL2 CCB.

The migration principles described in the ECDSA signature computation using software key use case and the ECDSA signature computation using hardware key use case are also applicable to ECC scalar multiplication and RSA modular exponentiation operations.

Similarly, the migration principles described in the ECDSA signature computation using RNG with software key use case and the ECDSA signature computation using RNG with hardware key use case are also applicable to ECC scalar multiplication.

Note

Signing a message using the software or hardware-wrapped private key blob is only available in ECDSA mode.

The same programming sequences are preserved between HAL1 and HAL2 , only some minor APIs naming are applied in HAL2.


HAL CCB compute ECDSA signature using software key

Sequence diagram

HAL1

HAL2

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as CCB

App -> CCB : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Wrapping key ==
App -> CCB : HAL_CCB_ECDSA_WrapSymmetricKey()
activate CCB
note right : Wrap the clear-text symmetric key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==
App -> CCB : HAL_CCB_ECDSA_WrapPrivateKey()
activate CCB
note right : Create the ECDSA private-key blob using the wrapped key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob usage ==
App -> CCB : HAL_CCB_ECDSA_Sign()
activate CCB
note right : Compute the signature parts r and s
CCB --> App : HAL_OK
deactivate CCB
note left : return

App -> CCB : HAL_CCB_ECDSA_ComputePublicKey()
activate CCB
note right : Compute public key coordinates x and y
CCB --> App : HAL_OK
deactivate CCB
note left : return
@enduml

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as  CCB

App -> CCB  : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App :HAL_OK
deactivate CCB
note left : return

== Wrapping key ==
App -> CCB  : HAL_CCB_ECDSA_WrapSymmetricKey()
activate CCB
note right : Wrap the clear text from the user with an AES-algorithm
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==

App -> CCB  : HAL_CCB_ECDSA_SW_WrapPrivateKey()
note right : Create the ECDSCA key blob using the wrapped key
CCB --> App : HAL_OK
note left : return

== Blob usage ==
App -> CCB  : HAL_CCB_ECDSA_SW_Sign()
activate CCB
note right :Compute the signature (part r, part s)
CCB --> App :HAL_OK
deactivate CCB
note left : return
App -> CCB  : HAL_CCB_ECDSA_SW_ComputePublicKey()
activate CCB
note right :Compute public key (coordinate x, coordinate y)
CCB --> App :HAL_OK
note left : return
deactivate CCB
@enduml

Code snippet

HAL1

HAL2

CCB_HandleTypeDef hccb;
CCB_WrappingKeyTypeDef wrappedKeyConf;
CCB_ECDSACurveParamTypeDef ECDSAparam;
CCB_ECDSAKeyBlobTypeDef ECDSAKeyBlob;
CCB_ECDSASignTypeDef Signature;
CCB_ECCMulPointTypeDef publickeyOut;
/* Initialize the CCB peripheral */
HAL_CCB_Init(&hccb);
/* Configure Wrapped Key */
wrappedKeyConf.WrappingKeyType         = HAL_CCB_USER_KEY_WRAPPED;
wrappedKeyConf.pInitVect               = AESIV;
wrappedKeyConf.AES_Algorithm           = CCB_AES_CBC;
wrappedKeyConf.pUserWrappedWrappingKey = Wrapped_key_Buffer;
HAL_CCB_ECDSA_WrapSymmetricKey(&hccb, Symetric_AESKey256, &wrappedKeyConf);
/* Prepare ECDSA out parameters */
ECDSAKeyBlob.pIV                       = IV_Buffer;
ECDSAKeyBlob.pTag                      = TAG_Buffer;
ECDSAKeyBlob.pWrappedKey               = PrivateKey_encrypted_192;
/* Fill ECDSA parameters */
ECDSAparam.primeOrderSizeByte          = ecdsa192_n_length;
ECDSAparam.modulusSizeByte             = ecdsa192_p_length;
ECDSAparam.coefSignA                   = ecdsa192_a_sign;
ECDSAparam.pAbsCoefA                   = ecdsa192_a_abs;
ECDSAparam.pCoefB                      = ecdsa192_b;
ECDSAparam.pModulus                    = ecdsa192_p;
ECDSAparam.pPrimeOrder                 = ecdsa192_n;
ECDSAparam.pPointX                     = ecdsa192_Gx;
ECDSAparam.pPointY                     = ecdsa192_Gy;


HAL_CCB_ECDSA_WrapPrivateKey(&hccb, &ECDSAparam, ecdsa192_Prvt_keyP, &wrappedKeyConf, &ECDSAKeyBlob);
/* Prepare signature field */
Signature.pSSign                       = ECDSASout_192;
Signature.pRSign                       = ECDSARout_192;
HAL_CCB_ECDSA_Sign(&hccb, &ECDSAparam, &wrappedKeyConf, &ECDSAKeyBlob, ECDSAHash_192, &Signature);
/* Blob use for signing public key computation */
publickeyOut.pPointX                   = PublicKeyXout_192;
publickeyOut.pPointY                   = PublicKeyYout_192;
HAL_CCB_ECDSA_ComputePublicKey(&hccb, &ECDSAparam, &wrappedKeyConf, &ECDSAKeyBlob, &publickeyOut);
hal_ccb_handle_t hccb;
hal_ccb_wrapping_sw_key_context_t wrappedKeyConf;
hal_ccb_ecdsa_curve_param_t ECDSAparam;
hal_ccb_ecdsa_key_blob_t ECDSAKeyBlob;
hal_ccb_ecdsa_sign_t Signature;
hal_ccb_ecc_point_t publickeyOut;
/* Initialize the CCB peripheral */
HAL_CCB_Init(&hccb, HAL_CCB);
/* Configure wrapped key */
wrappedKeyConf.p_init_vect                   = AESIV;
wrappedKeyConf.aes_algorithm                 = CCB_AES_CBC;
wrappedKeyConf.key_size                      = 256;

HAL_CCB_ECDSA_WrapSymmetricKey(&hccb, Symetric_AESKey256, &wrappedKeyConf, Wrapped_key_Buffer);
/* Prepare ECDSA out parameters */
ECDSAKeyBlob.p_iv                            = IV_Buffer;
ECDSAKeyBlob.p_tag                           = TAG_Buffer;
ECDSAKeyBlob.p_wrapped_key                   = PrivateKey_encrypted_192;
/* Fill ECDSA parameters */
ECDSAparam.prime_order_size_byte             = ecdsa192_n_length;
ECDSAparam.modulus_size_byte                 = ecdsa192_p_length;
ECDSAparam.coef_sign_a                       = ecdsa192_a_sign;
ECDSAparam.p_abs_coef_a                      = ecdsa192_a_abs;
ECDSAparam.p_coef_b                          = ecdsa192_b;
ECDSAparam.p_modulus                         = ecdsa192_p;
ECDSAparam.p_prime_order                     = ecdsa192_n;
ECDSAparam.p_point_x                         = ecdsa192_Gx;
ECDSAparam.p_point_y                         = ecdsa192_Gy;
ECDSAparam.ecdsa_pool_buffer.p_buff          = ccb_pool_buffer;
ECDSAparam.ecdsa_pool_buffer.buff_size_byte  = HAL_CCB_ECDSA_CALC_BUFFER_SIZE(ecdsa192_p_length);
HAL_CCB_ECDSA_SW_WrapPrivateKey(&hccb, &ECDSAparam, ecdsa192_Prvt_keyP, &wrappedKeyConf, Wrapped_key_Buffer, &ECDSAKeyBlob);
/* Prepare signature field */
Signature.p_s_sign                           = ECDSASout_192;
Signature.p_r_sign                           = ECDSARout_192;
HAL_CCB_ECDSA_SW_Sign(&hccb, &ECDSAparam, &wrappedKeyConf, Wrapped_key_Buffer, &ECDSAKeyBlob, ECDSAHash_192, 24, &Signature);
/* Blob use for signing public key computation */
publickeyOut.p_point_x                       = PublicKeyXout_192;
publickeyOut.p_point_y                       = PublicKeyYout_192;
HAL_CCB_ECDSA_SW_ComputePublicKey(&hccb, &ECDSAparam, &wrappedKeyConf, Wrapped_key_Buffer, &ECDSAKeyBlob, &publickeyOut);

HAL CCB compute ECDSA signature using hardware key

Sequence diagram

HAL1

HAL2

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as CCB

App -> CCB : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==
App -> CCB : HAL_CCB_ECDSA_WrapPrivateKey()
activate CCB
note right : Create the ECDSA private-key blob using a hardware key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob usage ==
App -> CCB : HAL_CCB_ECDSA_Sign()
activate CCB
note right : Compute the signature parts r and s
CCB --> App : HAL_OK
deactivate CCB
note left : return
App -> CCB : HAL_CCB_ECDSA_ComputePublicKey()
activate CCB
note right : Compute public key coordinates x and y
CCB --> App : HAL_OK
deactivate CCB
note left : return

@enduml

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as CCB

App -> CCB : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==
App -> CCB : HAL_CCB_ECDSA_HW_WrapPrivateKey()
activate CCB
note right : Create the ECDSA private-key blob using a hardware key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob usage ==
App -> CCB : HAL_CCB_ECDSA_HW_Sign()
activate CCB
note right : Compute the signature (part r, part s)
CCB --> App : HAL_OK
deactivate CCB
note left : return

group authenticity and integrity verification using HAL PKA driver
App -> CCB : HAL_CCB_ECDSA_HW_ComputePublicKey()
activate CCB
note right : Compute public key (coordinate x, coordinate y)
CCB --> App : HAL_OK
deactivate CCB
note left : return

@enduml

Code snippet

HAL1

HAL2

CCB_HandleTypeDef hccb;
CCB_WrappingKeyTypeDef wrappedKeyConf;
CCB_ECDSACurveParamTypeDef ECDSAparam;
CCB_ECDSAKeyBlobTypeDef ECDSAKeyBlob;
CCB_ECDSASignTypeDef Signature;
CCB_ECCMulPointTypeDef publickeyOut;
HAL_CCB_Init(&hccb);
wrappedKeyConf.WrappingKeyType = HAL_CCB_USER_KEY_HW;

ECDSAKeyBlob.pIV               = IV_Buffer;
ECDSAKeyBlob.pTag              = TAG_Buffer;
ECDSAKeyBlob.pWrappedKey       = PrivateKey_encrypted_192;
ECDSAparam.primeOrderSizeByte  = ecdsa192_n_length;
ECDSAparam.modulusSizeByte     = ecdsa192_p_length;
ECDSAparam.coefSignA           = ecdsa192_a_sign;
ECDSAparam.pAbsCoefA           = ecdsa192_a_abs;
ECDSAparam.pCoefB              = ecdsa192_b;
ECDSAparam.pModulus            = ecdsa192_p;
ECDSAparam.pPrimeOrder         = ecdsa192_n;
ECDSAparam.pPointX             = ecdsa192_Gx;
ECDSAparam.pPointY             = ecdsa192_Gy;


HAL_CCB_ECDSA_WrapPrivateKey(&hccb, &ECDSAparam, ecdsa192_Prvt_keyP,
                             &wrappedKeyConf, &ECDSAKeyBlob);

Signature.pSSign               = ECDSASout_192;
Signature.pRSign               = ECDSARout_192;

HAL_CCB_ECDSA_Sign(&hccb, &ECDSAparam, &wrappedKeyConf,
                   &ECDSAKeyBlob, ECDSAHash_192, &Signature);

publickeyOut.pPointX           = PublicKeyXout_192;
publickeyOut.pPointY           = PublicKeyYout_192;

HAL_CCB_ECDSA_ComputePublicKey(&hccb, &ECDSAparam, &wrappedKeyConf,
                               &ECDSAKeyBlob, &publickeyOut);
hal_ccb_handle_t hccb;
hal_ccb_wrapping_sw_key_context_t wrappedKeyConf;
hal_ccb_ecdsa_curve_param_t ECDSAparam;
hal_ccb_ecdsa_key_blob_t ECDSAKeyBlob;
hal_ccb_ecdsa_sign_t Signature;
hal_ccb_ecc_point_t publickeyOut;
HAL_CCB_Init(&hccb, HAL_CCB);

ECDSAKeyBlob.p_iv                            = IV_Buffer;
ECDSAKeyBlob.p_tag                           = TAG_Buffer;
ECDSAKeyBlob.p_wrapped_key                   = PrivateKey_encrypted_192;
ECDSAparam.prime_order_size_byte             = ecdsa192_n_length;
ECDSAparam.modulus_size_byte                 = ecdsa192_p_length;
ECDSAparam.coef_sign_a                       = ecdsa192_a_sign;
ECDSAparam.p_abs_coef_a                      = ecdsa192_a_abs;
ECDSAparam.p_coef_b                          = ecdsa192_b;
ECDSAparam.p_modulus                         = ecdsa192_p;
ECDSAparam.p_prime_order                     = ecdsa192_n;
ECDSAparam.p_point_x                         = ecdsa192_Gx;
ECDSAparam.p_point_y                         = ecdsa192_Gy;
ECDSAparam.ecdsa_pool_buffer.p_buff          = ccb_pool_buffer;
ECDSAparam.ecdsa_pool_buffer.buff_size_byte  = HAL_CCB_ECDSA_CALC_BUFFER_SIZE(ecdsa192_p_length);

HAL_CCB_ECDSA_HW_WrapPrivateKey(&hccb, &ECDSAparam, ecdsa192_Prvt_keyP,
                                HAL_CCB_KEY_HW, &ECDSAKeyBlob);

Signature.p_s_sign                           = ECDSASout_192;
Signature.p_r_sign                           = ECDSARout_192;

HAL_CCB_ECDSA_HW_Sign(&hccb, &ECDSAparam, HAL_CCB_KEY_HW,
                      &ECDSAKeyBlob, ECDSAHash_192, 24, &Signature);

publickeyOut.p_point_x                       = PublicKeyXout_192;
publickeyOut.p_point_y                       = PublicKeyYout_192;

HAL_CCB_ECDSA_HW_ComputePublicKey(&hccb, &ECDSAparam,
                                  HAL_CCB_KEY_HW, &ECDSAKeyBlob, &publickeyOut);

HAL CCB compute ECDSA signature using RNG with software key

Sequence diagram

HAL1

HAL2

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as CCB
App -> CCB : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Wrapping key ==
App -> CCB : HAL_CCB_ECDSA_WrapSymmetricKey()
activate CCB
note right : Wrap the clear-text symmetric key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==
App -> CCB : HAL_CCB_ECDSA_GenerateWrapPrivateKey()
activate CCB
note right : Generate an RNG private key and create the ECDSA blob using the wrapped key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob usage ==
App -> CCB : HAL_CCB_ECDSA_Sign()
activate CCB
note right : Compute the signature parts r and s
CCB --> App : HAL_OK
deactivate CCB
note left : return

App -> CCB : HAL_CCB_ECDSA_ComputePublicKey()
activate CCB
note right : Compute public key coordinates x and y
CCB --> App : HAL_OK
deactivate CCB
note left : return

@enduml

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as  CCB

App -> CCB  : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Wrapping key ==
App -> CCB  : HAL_CCB_ECDSA_WrapSymmetricKey()
activate CCB
note right : Wrap the clear text from the user with an AES-algorithm
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==

App -> CCB  : HAL_CCB_ECDSA_SW_GenerateWrapPrivateKey()
note right : Create the ECDSCA key blob using RNG
CCB --> App : HAL_OK
note left : return

== Blob usage ==
App -> CCB  : HAL_CCB_ECDSA_SW_Sign()
activate CCB
note right :Compute the signature (part r, part s)
CCB --> App : HAL_OK
deactivate CCB
note left : return
App -> CCB  : HAL_CCB_ECDSA_SW_ComputePublicKey()
activate CCB
note right :Compute public key (coordinate x, coordinate y)
CCB --> App : HAL_OK
note left : return
deactivate CCB

@enduml

Code snippet

HAL1

HAL2

CCB_HandleTypeDef hccb;
CCB_WrappingKeyTypeDef wrappedKeyConf;
CCB_ECDSACurveParamTypeDef ECDSAparam;
CCB_ECDSAKeyBlobTypeDef ECDSAKeyBlob;
CCB_ECDSASignTypeDef Signature;
CCB_ECCMulPointTypeDef publickeyOut;
HAL_CCB_Init(&hccb);

wrappedKeyConf.WrappingKeyType         = HAL_CCB_USER_KEY_WRAPPED;
wrappedKeyConf.pInitVect               = AESIV;
wrappedKeyConf.AES_Algorithm           = CCB_AES_CBC;
wrappedKeyConf.pUserWrappedWrappingKey = Wrapped_key_Buffer;
HAL_CCB_ECDSA_WrapSymmetricKey(&hccb, Symetric_AESKey256, &wrappedKeyConf);

ECDSAKeyBlob.pIV                       = IV_Buffer;
ECDSAKeyBlob.pTag                      = TAG_Buffer;
ECDSAKeyBlob.pWrappedKey               = PrivateKey_encrypted_192;
ECDSAparam.primeOrderSizeByte          = ecdsa192_n_length;
ECDSAparam.modulusSizeByte             = ecdsa192_p_length;
ECDSAparam.coefSignA                   = ecdsa192_a_sign;
ECDSAparam.pAbsCoefA                   = ecdsa192_a_abs;
ECDSAparam.pCoefB                      = ecdsa192_b;
ECDSAparam.pModulus                    = ecdsa192_p;
ECDSAparam.pPrimeOrder                 = ecdsa192_n;
ECDSAparam.pPointX                     = ecdsa192_Gx;
ECDSAparam.pPointY                     = ecdsa192_Gy;



HAL_CCB_ECDSA_GenerateWrapPrivateKey(&hccb, &ECDSAparam,
                                     &wrappedKeyConf,
                                      &ECDSAKeyBlob);

Signature.pSSign                       = ECDSASout_192;
Signature.pRSign                       = ECDSARout_192;

HAL_CCB_ECDSA_Sign(&hccb, &ECDSAparam, &wrappedKeyConf,
                   &ECDSAKeyBlob, ECDSAHash_192, &Signature);


publickeyOut.pPointX                   = PublicKeyXout_192;
publickeyOut.pPointY                   = PublicKeyYout_192;
HAL_CCB_ECDSA_ComputePublicKey(&hccb, &ECDSAparam, &wrappedKeyConf,
                               &ECDSAKeyBlob,
                               &publickeyOut);
hal_ccb_handle_t hccb;
hal_ccb_wrapping_sw_key_context_t wrappedKeyConf;
hal_ccb_ecdsa_curve_param_t ECDSAparam;
hal_ccb_ecdsa_key_blob_t ECDSAKeyBlob;
hal_ccb_ecdsa_sign_t Signature;
hal_ccb_ecc_point_t publickeyOut;
HAL_CCB_Init(&hccb, HAL_CCB);


wrappedKeyConf.p_init_vect                   = AESIV;
wrappedKeyConf.aes_algorithm                 = CCB_AES_CBC;
wrappedKeyConf.key_size                      = 256;
HAL_CCB_ECDSA_WrapSymmetricKey(&hccb, Symetric_AESKey256, &wrappedKeyConf, Wrapped_key_Buffer);

ECDSAKeyBlob.p_iv                            = IV_Buffer;
ECDSAKeyBlob.p_tag                           = TAG_Buffer;
ECDSAKeyBlob.p_wrapped_key                   = PrivateKey_encrypted_192;
ECDSAparam.prime_order_size_byte             = ecdsa192_n_length;
ECDSAparam.modulus_size_byte                 = ecdsa192_p_length;
ECDSAparam.coef_sign_a                       = ecdsa192_a_sign;
ECDSAparam.p_abs_coef_a                      = ecdsa192_a_abs;
ECDSAparam.p_coef_b                          = ecdsa192_b;
ECDSAparam.p_modulus                         = ecdsa192_p;
ECDSAparam.p_prime_order                     = ecdsa192_n;
ECDSAparam.p_point_x                         = ecdsa192_Gx;
ECDSAparam.p_point_y                         = ecdsa192_Gy;
ECDSAparam.ecdsa_pool_buffer.p_buff          = ccb_pool_buffer;
ECDSAparam.ecdsa_pool_buffer.buff_size_byte  = HAL_CCB_ECDSA_CALC_BUFFER_SIZE(ecdsa192_p_length);

HAL_CCB_ECDSA_SW_GenerateWrapPrivateKey(&hccb, &ECDSAparam,
                                        &wrappedKeyConf, Wrapped_key_Buffer,
                                        &ECDSAKeyBlob);

Signature.p_s_sign                           = ECDSASout_192;
Signature.p_r_sign                           = ECDSARout_192;

HAL_CCB_ECDSA_SW_Sign(&hccb, &ECDSAparam, &wrappedKeyConf,
                      Wrapped_key_Buffer, &ECDSAKeyBlob,
                      ECDSAHash_192, 24, &Signature);

publickeyOut.p_point_x                       = PublicKeyXout_192;
publickeyOut.p_point_y                       = PublicKeyYout_192;
HAL_CCB_ECDSA_SW_ComputePublicKey(&hccb, &ECDSAparam, &wrappedKeyConf,
                                  Wrapped_key_Buffer, &ECDSAKeyBlob,
                                  &publickeyOut);

HAL CCB compute ECDSA signature using RNG with hardware key

Sequence diagram

HAL1

HAL2

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as CCB

App -> CCB : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==
App -> CCB : HAL_CCB_ECDSA_GenerateWrapPrivateKey()
activate CCB
note right : Generate an RNG private key and create the ECDSA blob using a hardware key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob usage ==
App -> CCB : HAL_CCB_ECDSA_Sign()
activate CCB
note right : Compute the signature parts r and s
CCB --> App : HAL_OK
deactivate CCB
note left : return

App -> CCB : HAL_CCB_ECDSA_ComputePublicKey()
activate CCB
note right : Compute public key coordinates x and y
CCB --> App : HAL_OK
deactivate CCB
note left : return

@enduml

@startuml
==Initialization==

participant "User application" as App
participant "HAL CCB Driver" as CCB

App -> CCB : HAL_CCB_Init()
activate CCB
note right : Initialize the CCB handle and associate an instance
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob creation ==

App -> CCB : HAL_CCB_ECDSA_HW_GenerateWrapPrivateKey()
activate CCB
note right : Generate an RNG private key and create the ECDSA blob using a hardware key
CCB --> App : HAL_OK
deactivate CCB
note left : return

== Blob usage ==
App -> CCB : HAL_CCB_ECDSA_HW_Sign()
activate CCB
note right : Compute the signature (part r, part s)
CCB --> App : HAL_OK
deactivate CCB
note left : return
App -> CCB : HAL_CCB_ECDSA_HW_ComputePublicKey()
activate CCB
note right : Compute public key (coordinate x, coordinate y)
CCB --> App : HAL_OK
note left : return
deactivate CCB
@enduml

Code snippet

HAL1

HAL2

CCB_HandleTypeDef hccb;
CCB_WrappingKeyTypeDef wrappedKeyConf;
CCB_ECDSACurveParamTypeDef ECDSAparam;
CCB_ECDSAKeyBlobTypeDef ECDSAKeyBlob;
CCB_ECDSASignTypeDef Signature;
CCB_ECCMulPointTypeDef publickeyOut;
HAL_CCB_Init(&hccb);

wrappedKeyConf.WrappingKeyType         = HAL_CCB_USER_KEY_HW;
ECDSAKeyBlob.pIV                       = IV_Buffer;
ECDSAKeyBlob.pTag                      = TAG_Buffer;
ECDSAKeyBlob.pWrappedKey               = PrivateKey_encrypted_192;

ECDSAparam.primeOrderSizeByte          = ecdsa192_n_length;
ECDSAparam.modulusSizeByte             = ecdsa192_p_length;
ECDSAparam.coefSignA                   = ecdsa192_a_sign;
ECDSAparam.pAbsCoefA                   = ecdsa192_a_abs;
ECDSAparam.pCoefB                      = ecdsa192_b;
ECDSAparam.pModulus                    = ecdsa192_p;
ECDSAparam.pPrimeOrder                 = ecdsa192_n;
ECDSAparam.pPointX                     = ecdsa192_Gx;
ECDSAparam.pPointY                     = ecdsa192_Gy;

HAL_CCB_ECDSA_GenerateWrapPrivateKey(&hccb, &ECDSAparam,
                                     &wrappedKeyConf, &ECDSAKeyBlob);

Signature.pSSign                       = ECDSASout_192;
Signature.pRSign                       = ECDSARout_192;
HAL_CCB_ECDSA_Sign(&hccb, &ECDSAparam, &wrappedKeyConf,
                   &ECDSAKeyBlob, ECDSAHash_192, &Signature);

publickeyOut.pPointX                   = PublicKeyXout_192;
publickeyOut.pPointY                   = PublicKeyYout_192;
HAL_CCB_ECDSA_ComputePublicKey(&hccb, &ECDSAparam, &wrappedKeyConf,
                               &ECDSAKeyBlob,
                               &publickeyOut);
hal_ccb_handle_t hccb;
hal_ccb_wrapping_sw_key_context_t wrappedKeyConf;
hal_ccb_ecdsa_curve_param_t ECDSAparam;
hal_ccb_ecdsa_key_blob_t ECDSAKeyBlob;
hal_ccb_ecdsa_sign_t Signature;
hal_ccb_ecc_point_t publickeyOut;
HAL_CCB_Init(&hccb, HAL_CCB);

ECDSAKeyBlob.p_iv                            = IV_Buffer;
ECDSAKeyBlob.p_tag                           = TAG_Buffer;
ECDSAKeyBlob.p_wrapped_key                   = PrivateKey_encrypted_192;

ECDSAparam.prime_order_size_byte             = ecdsa192_n_length;
ECDSAparam.modulus_size_byte                 = ecdsa192_p_length;
ECDSAparam.coef_sign_a                       = ecdsa192_a_sign;
ECDSAparam.p_abs_coef_a                      = ecdsa192_a_abs;
ECDSAparam.p_coef_b                          = ecdsa192_b;
ECDSAparam.p_modulus                         = ecdsa192_p;
ECDSAparam.p_prime_order                     = ecdsa192_n;
ECDSAparam.p_point_x                         = ecdsa192_Gx;
ECDSAparam.p_point_y                         = ecdsa192_Gy;
ECDSAparam.ecdsa_pool_buffer.p_buff          = ccb_pool_buffer;
ECDSAparam.ecdsa_pool_buffer.buff_size_byte  = HAL_CCB_ECDSA_CALC_BUFFER_SIZE(ecdsa192_p_length);
HAL_CCB_ECDSA_HW_GenerateWrapPrivateKey(&hccb, &ECDSAparam,
                                        HAL_CCB_KEY_HW, &ECDSAKeyBlob);

Signature.p_s_sign                           = ECDSASout_192;
Signature.p_r_sign                           = ECDSARout_192;
HAL_CCB_ECDSA_HW_Sign(&hccb, &ECDSAparam, HAL_CCB_KEY_HW,
                      &ECDSAKeyBlob, ECDSAHash_192, 24, &Signature);

publickeyOut.p_point_x                       = PublicKeyXout_192;
publickeyOut.p_point_y                       = PublicKeyYout_192;
HAL_CCB_ECDSA_HW_ComputePublicKey(&hccb, &ECDSAparam,
                                  HAL_CCB_KEY_HW,
                                  &ECDSAKeyBlob, &publickeyOut);